package com.example.zzl.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/1/7.
 */

public class BaseFragmentPagerAdapter extends FragmentPagerAdapter {

    private  String[] titles;
    public List<Fragment> list;

    public BaseFragmentPagerAdapter(FragmentManager fm, List<Fragment> list) {
        this(fm ,list, null);
    }

    public BaseFragmentPagerAdapter(FragmentManager fm, List<Fragment> list, String[] titles) {
        super(fm);
        this.list = list;
        this.titles = titles;
    }



    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (titles.length > 0) {
            return titles[position];
        }
        return super.getPageTitle(position);
    }
}
